import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:ff_flutter/routes/app_routes.dart';

class MenuItem {
  final String icon;
  final String title;

  MenuItem(this.icon, this.title);
}

class MenuList extends StatelessWidget {
  final List<MenuItem> menuItems = [
    MenuItem('assets/images/account_icon1.png', 'Bill'),
    MenuItem('assets/images/account_icon2.png', 'Product Management'),
    MenuItem('assets/images/account_icon3.png', 'Order History'),
    MenuItem('assets/images/account_icon4.png', 'Historical'),
    MenuItem('assets/images/account_icon5.png', 'Invite Friends'),
    MenuItem(
        'assets/images/account_icon6.png', 'Apply to become a broadcaster'),
  ];

  final List<MenuItem> systemMenuItems = [
    MenuItem('assets/images/account_icon7.png', 'Online Service'),
    MenuItem('assets/images/account_icon8.png', 'Security Center'),
    MenuItem('assets/images/account_icon9.png', 'Help Center'),
  ];

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.symmetric(horizontal: 30.w),
      child: Column(
        children: [
          ...menuItems.map((item) => _buildMenuItem(item)).toList(),
          Container(
            height: 1.h,
            color: const Color(0xFF393939),
          ),
          SizedBox(height: 70.h),
          ...systemMenuItems
              .map((item) => _buildMenuItem(item, isSystem: true))
              .toList(),
        ],
      ),
    );
  }

  Widget _buildMenuItem(MenuItem item, {bool isSystem = false}) {
    return Column(
      children: [
        GestureDetector(
          onTap: () {
            if (isSystem) {
              if (item.title == 'Help Center') {
                Get.toNamed(AppRoutes.HELP_CENTER);
              } else if (item.title == 'Security Center') {
                Get.toNamed(AppRoutes.SECURITY_CENTER);
              }
            } else if (item.title == 'Apply to become a broadcaster') {
              Get.toNamed(AppRoutes.ANCHOR_APPLY);
            } else if (item.title == 'Invite Friends') {
              Get.toNamed(AppRoutes.INVITE_FRIENDS);
            }
          },
          child: Container(
            height: 116.h,
            width: double.infinity,
            alignment: Alignment.center,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Expanded(
                  child: Row(
                    children: [
                      Image.asset(
                        item.icon,
                        width: 48.w,
                        height: 48.h,
                      ),
                      SizedBox(width: 24.w),
                      Expanded(
                        child: Text(
                          item.title,
                          style: TextStyle(
                            color: Colors.white,
                            fontSize: 32.sp,
                            fontWeight: FontWeight.bold,
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
                Icon(
                  Icons.chevron_right,
                  color: Colors.white,
                  size: 48.sp,
                ),
              ],
            ),
          ),
        ),
      ],
    );
  }
}
